function observ = acc_hfun(modelObject,observObject, state, N, U2)

%  HFUN_JOINT  State observation function of meta system for joint estimation
%
%    observ = hfun_joint(InferenceDS, state, N, U2)
%
%    INPUT
%         InferenceDS     : (InferenceDS) Inference data structure
%         state           : (c-vector) meta system state vector
%         N               : (c-vector) meta system observation noise vector
%         U2              : (c-vector) meta system exogenous input 2
%    OUTPUT
%         observ          : (c-vector)  meta system observation vector

[dim,nov] = size(state);
observ = zeros(observObject.dim,nov);
dimX  = modelObject.statedim;

for k=1:nov,
    %   InferenceDS.model = InferenceDS.model.setparams( InferenceDS.model, state(dimX+1:end,k), InferenceDS.paramParamIdxVec);    % set model parameter vector
    observ(:,k) = hfun(state(1:dimX,k), N(:,k), U2);
end


function observ = hfun(state, N, U2)
observ = hx(state,U2) + N;


function yp = hx(x, U)
yp = zeros(3,1);
q0 = x(1);
q1 = x(2);
q2 = x(3);
q3 = x(4);

% acc
yp(1) = 2*(q1*q3 - q0*q2);
yp(2) =  2*(q2*q3 + q0*q1);
yp(3) = 1 - 2*(q1*q1 + q2*q2);